package org.infinitest.intellij.idea.facet;

import javax.swing.*;

import com.intellij.facet.Facet;
import com.intellij.facet.FacetType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.util.IconLoader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class InfinitestFacetType extends FacetType<InfinitestFacet, InfinitestFacetConfiguration>
{
  public static final InfinitestFacetType INSTANCE = new InfinitestFacetType();

  private InfinitestFacetType()
  {
    super(InfinitestFacet.ID, "Infinitest", "Infinitest");
  }

  public InfinitestFacetConfiguration createDefaultConfiguration()
  {
    return new InfinitestFacetConfiguration();
  }

  public InfinitestFacet createFacet(@NotNull Module module, String name,
    @NotNull InfinitestFacetConfiguration configuration, @Nullable Facet underlyingFacet)
  {
    return new InfinitestFacet(this, module, name, configuration, underlyingFacet);
  }

  public Icon getIcon()
  {
    return IconLoader.getIcon("/infinitest.png");
  }

  public boolean isSuitableModuleType(ModuleType moduleType)
  {
    return moduleType.equals(StdModuleTypes.JAVA) || "PLUGIN_MODULE".equals(moduleType.getId());
  }
}
